<jsp:include page="header.jsp">
			<jsp:param value="null" name="item"/>
</jsp:include>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.text.SimpleDateFormat" %>
<%@page import="java.util.Date" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<section class="content">
	<section class="widget"  id="department" >
		<header>
			<span class="icon">&#128196;</span>
			<hgroup>
				<h1>点数兑换</h1>
				<h2>兑换列表</h2>
			</hgroup>
		</header>
		<div class="content">
  <div class="tabs" id="tabs">
	    <ul>
	        <li class="on">现金兑换</li>
	        <li>物品兑换</li>
	        <li>兑换记录</li>
	    </ul>
	    <div id="exchangeMoney">
	    		<!-- <s:property value="message" /> -->
				<s:form action="exchange" method="post">
				<ol>
		   		<li>我的点数：<input type="text" readonly="readonly" value="${userInfo.count}"/></li>
		   		<li>兑率：<input type="text" readonly="readonly" value="${rule.rate}"/>点数/元</li>
		   		<li>兑换金额：<input type="text" name="count"/></li>
				<li><input type="hidden" name="gift.giftName" value="现金"/>
					   		<input type="submit" class="button white" value="兑换" />    
					   		<input type="reset" class="button white" value="重置" />
				</li>
				</ol>
   				</s:form>
	    </div>
	    
	    <div class="hide" id="exchangeGift"> 
    			<s:if test='giftList == null || giftList.size == 1&&giftList[0].giftName =="现金"'>
    				无可兑换的物品！！！
    			</s:if>
    			<s:else>
					<s:form action="exchange" method="post">
					<ol>
				   		<li>我的点数：<input type="text" readonly="readonly" value="${userInfo.count}"/></li>
				   		<li>兑率：<input type="text" readonly="readonly" value="${rule.rate}"/>点数/元</li>
				   		<li>兑换物品[名称，价值(元),数量]：<s:select name="gift.giftId" list="giftList.{?#this.giftName != '现金'}" listKey="giftId" listValue="giftName+'：'+giftValue+' ， '+number"/></li>
						<li>兑换物品数量：	 <input type="text" name="count"/></li>
						<li>
							   		<input type="submit" class="button white" value="兑换" />    
							   		<input type="reset" class="button white" value="重置" />
						</li>
					</ol>
			   		</s:form>
		   		</s:else>
	    </div>
	     <div class="hide" id="loadPersonalExchangeRecord"> 
    			<s:if test='exchangeRecordList == null || exchangeRecordList.size == 0'>
    				无兑换记录！！！
    			</s:if>
    			<s:else>
					<s:form action="loadPersonalExchangeRecord" method="post">
					
										<table id="myTable">
						<tr>
							<th>时间</th>
							<th>物品</th>
							<th>数量</th>
							<th>花费点数</th>
							<th>是否已领取</th>
						</tr>
					
							<s:iterator value="exchangeRecordList" id="exchangeRecord" status="st">
						
							<tr>
								<td><s:property value="dateList[#st.index]" />
								</td>
								<td><s:property value="#exchangeRecord.gift.giftName" /></td>
								<td><s:property value="#exchangeRecord.number" /></td>
								<td><s:property value="#exchangeRecord.points" /></td>
								<td><s:property value="#exchangeRecord.exchangeStatus" /></td>
							</tr>
							</s:iterator>
						
					</table>
			   		</s:form>
		   		</s:else>
	    </div>
   </div>
   </div>
   </section>
<script type="text/javascript">
   var oTab = document.getElementById("tabs");
   var oUl = oTab.getElementsByTagName("ul")[0];
   var oLis = oUl.getElementsByTagName("li");
   var oDivs= oTab.getElementsByTagName("div");

   for(var i= 0,len = oLis.length;i<len;i++){  
       oLis[i].index = i;
       oLis[i].onclick = function() {
           for(var n= 0;n<len;n++){
               oLis[n].className = "";
               oDivs[n].className = "hide";//隐藏的类名
           }
           this.className = "on";//显示的类名
           oDivs[this.index].className = "";
           var index = this.index;
       };
   }
   	var message="<%=request.getAttribute("message")%>";
		if(message!="null"){
			alert(message);
		}
</script>
<%@ include file="footer.jsp" %>
